/**
author: sailing
date: 2016/11/21
****/
<style lang='less'>
.el-select .el-input {
  width: 120px;
}
.search {
  position:absolute;
  right:5px;
  left:50%;
  margin-left:-300px;
  width: 600px;
  z-index:4000;
}
</style>

<template>
  <div class='search'>
    <el-date-picker
      v-model="valueDate"
      size='large'
      style='width:300px'
      type="daterange"
      :change='change()'
      placeholder="选择日期范围">
    </el-date-picker>
  </div>
</template>
<script>
import Vue from 'vue'
import eventBus from '../eventBus'
export default {
  data () {
    return {
      left: 180,
      input5: '',
      prepend: '名称',
      endTime: '',
      startTime: '',
      valueDate: '',
      select: '1',
      flag: true
    }
  },
  methods: {
    getDate (str) {
      var newDate = new Date(str)
      console.log('newDate:', newDate)
      var month = newDate.getMonth() + 1
      var getDate = newDate.getDate()
      
      if (month < 10) month = '0' + month
      if (getDate < 10) getDate = '0' + getDate
      return newDate.getFullYear() + '-' + month + '-' + getDate
    },
    change (val) {
      // var arr = this.valueDate.split(',')
      if (!this.valueDate) return 
      
      var sd = {
        start: this.getDate(this.valueDate[0]),
        end: this.getDate(this.valueDate[1])
      }
      
      this.$parent.selectDate(sd)
    }
  }
}
</script>
